package cn.com.headfree.mouldshow.dao.impl;

import cn.com.headfree.entity.THonorInfo;
import cn.com.headfree.mouldshow.dao.THonorInfoDao;
import cn.com.headfree.vo.simple.HonorInfoVo;
import com.gta.edu.sdk.base.dao.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("/tHonorInfoDao")
public class THonorInfoDaoImpl extends BaseDaoImpl<THonorInfo> implements THonorInfoDao {


    @Override
    public List<HonorInfoVo> findByBaseorgId(String deptId) throws Exception {
        Object[] params = new Object[1];
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.honor_title,t.award_org,GET_DIC('JygexinQcJb',t.honor_level) as honor_level,GET_DIC('RuYuLeiBie',t.honor_type) as honor_type,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.xb_name as user_name from t_honor_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id INNER JOIN t_isc_user_tmp u on t.erp_no=u.hr_erp WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.honor_title,t.award_org,GET_DIC('JygexinQcJb',t.honor_level) as honor_level,GET_DIC('RuYuLeiBie',t.honor_type) as honor_type,t.acqu_time,DATE_FORMAT(t.acqu_time,'%Y-%m-%d %H:%i:%s') as acqu_time_str,u.`NAME` as user_name from t_honor_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
//        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.honor_title,t.award_org,GET_DIC('JygexinQcJb',t.honor_level) as honor_level,GET_DIC('RuYuLeiBie',t.honor_type) as honor_type,t.acqu_time,u.`NAME` as user_name from t_honor_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
        StringBuilder sql = new StringBuilder("select t.id,t.erp_no,t.honor_title,t.award_org,t.honor_level,t.honor_type,t.acqu_time,u.`NAME` as user_name from t_honor_info t INNER JOIN t_dept_emp_rela d on t.erp_no=d.erp_no INNER JOIN (select * from t_org_dept o where o.path like ?) o2 on o2.id=d.dept_id LEFT JOIN isc_user u on t.erp_no=u.FAX WHERE t.is_valid='0' AND t.del_sign='0' ORDER BY t.acqu_time DESC");
        params[0] = "%"+deptId+"%";
        return this.findAllBySQL(HonorInfoVo.class, sql.toString(), null, false, params);
    }
}
